{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import scipy.stats as stats\n",
    "import glob as glob\n",
    "import os"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Compute BONOBO networks\n",
    "\n",
    "To compute BONOBO networks we need a tab separated expression file, with samples on the columns and genes on the rows.\n",
    "\n",
    "In this case we have generated the file from the [Gene regulatory network reconstruction using single-cell RNA sequencing of barcoded genotypes in diverse environments](https://elifesciences.org/articles/51254) \n",
    "raw data ([GEO:SE125162](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE125162))  following these steps:\n",
    "\n",
    "Creating pseudobulk from raw counts: \n",
    "- group by Genotype and condition and averaging counts by gene. (132 genotype x condition, 6529 non-zero genes)\n",
    "- Remove genes there are always zero (GSE125162_all_pseudobulk_counts.txt)\n",
    "- df_nonzero_log = np.log(1+df_nonzero) (GSE125162_all_pseudobulk_logcounts.txt)\n",
    "\n",
    "The data is composed of 132 samples and 6520 genes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "ParserError",
     "evalue": "Error tokenizing data. C error: Calling read(nbytes) on source failed. Try engine='python'.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mParserError\u001b[0m                               Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m../data/raw/GSE125162_ALL-fastqTomat0-Counts.tsv\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m f:\n\u001b[0;32m----> 2\u001b[0m     raw \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mf\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msep\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;130;43;01m\\t\u001b[39;49;00m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m      3\u001b[0m \u001b[38;5;28mprint\u001b[39m(raw\u001b[38;5;241m.\u001b[39mshape)\n\u001b[1;32m      4\u001b[0m raw\u001b[38;5;241m.\u001b[39mhead()\n",
      "File \u001b[0;32m/opt/conda/envs/new-bonobo/lib/python3.9/site-packages/pandas/io/parsers/readers.py:1024\u001b[0m, in \u001b[0;36mread_csv\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[0m\n\u001b[1;32m   1011\u001b[0m kwds_defaults \u001b[38;5;241m=\u001b[39m _refine_defaults_read(\n\u001b[1;32m   1012\u001b[0m     dialect,\n\u001b[1;32m   1013\u001b[0m     delimiter,\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m   1020\u001b[0m     dtype_backend\u001b[38;5;241m=\u001b[39mdtype_backend,\n\u001b[1;32m   1021\u001b[0m )\n\u001b[1;32m   1022\u001b[0m kwds\u001b[38;5;241m.\u001b[39mupdate(kwds_defaults)\n\u001b[0;32m-> 1024\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m/opt/conda/envs/new-bonobo/lib/python3.9/site-packages/pandas/io/parsers/readers.py:624\u001b[0m, in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m    621\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m parser\n\u001b[1;32m    623\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m parser:\n\u001b[0;32m--> 624\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mparser\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnrows\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m/opt/conda/envs/new-bonobo/lib/python3.9/site-packages/pandas/io/parsers/readers.py:1921\u001b[0m, in \u001b[0;36mTextFileReader.read\u001b[0;34m(self, nrows)\u001b[0m\n\u001b[1;32m   1914\u001b[0m nrows \u001b[38;5;241m=\u001b[39m validate_integer(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnrows\u001b[39m\u001b[38;5;124m\"\u001b[39m, nrows)\n\u001b[1;32m   1915\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m   1916\u001b[0m     \u001b[38;5;66;03m# error: \"ParserBase\" has no attribute \"read\"\u001b[39;00m\n\u001b[1;32m   1917\u001b[0m     (\n\u001b[1;32m   1918\u001b[0m         index,\n\u001b[1;32m   1919\u001b[0m         columns,\n\u001b[1;32m   1920\u001b[0m         col_dict,\n\u001b[0;32m-> 1921\u001b[0m     ) \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43m  \u001b[49m\u001b[38;5;66;43;03m# type: ignore[attr-defined]\u001b[39;49;00m\n\u001b[1;32m   1922\u001b[0m \u001b[43m        \u001b[49m\u001b[43mnrows\u001b[49m\n\u001b[1;32m   1923\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m   1924\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[1;32m   1925\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mclose()\n",
      "File \u001b[0;32m/opt/conda/envs/new-bonobo/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py:234\u001b[0m, in \u001b[0;36mCParserWrapper.read\u001b[0;34m(self, nrows)\u001b[0m\n\u001b[1;32m    232\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m    233\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlow_memory:\n\u001b[0;32m--> 234\u001b[0m         chunks \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_reader\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mread_low_memory\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnrows\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    235\u001b[0m         \u001b[38;5;66;03m# destructive to chunks\u001b[39;00m\n\u001b[1;32m    236\u001b[0m         data \u001b[38;5;241m=\u001b[39m _concatenate_chunks(chunks)\n",
      "File \u001b[0;32mparsers.pyx:838\u001b[0m, in \u001b[0;36mpandas._libs.parsers.TextReader.read_low_memory\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mparsers.pyx:905\u001b[0m, in \u001b[0;36mpandas._libs.parsers.TextReader._read_rows\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mparsers.pyx:874\u001b[0m, in \u001b[0;36mpandas._libs.parsers.TextReader._tokenize_rows\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mparsers.pyx:891\u001b[0m, in \u001b[0;36mpandas._libs.parsers.TextReader._check_tokenize_status\u001b[0;34m()\u001b[0m\n",
      "File \u001b[0;32mparsers.pyx:2061\u001b[0m, in \u001b[0;36mpandas._libs.parsers.raise_parser_error\u001b[0;34m()\u001b[0m\n",
      "\u001b[0;31mParserError\u001b[0m: Error tokenizing data. C error: Calling read(nbytes) on source failed. Try engine='python'."
     ]
    }
   ],
   "source": [
    "with open('../data/raw/GSE125162_ALL-fastqTomat0-Counts.tsv', 'r') as f:\n",
    "    raw = pd.read_csv(f, sep = '\\t')\n",
    "print(raw.shape)\n",
    "raw.head()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(6829, 132)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "raw['sample'] = raw['Genotype_Group'] + '_' + raw['Condition']\n",
    "# We are actually using the average instead of the sum (suggested by Jonas)\n",
    "raw2 = raw.iloc[:,:-6]\n",
    "raw2['sample'] = raw['sample']\n",
    "pseudobulk = raw2.groupby(['sample']).mean().T\n",
    "pseudobulk.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>sample</th>\n",
       "      <th>WT(ho)_AmmoniumSulfate</th>\n",
       "      <th>WT(ho)_CStarve</th>\n",
       "      <th>WT(ho)_Glutamine</th>\n",
       "      <th>WT(ho)_MinimalEtOH</th>\n",
       "      <th>WT(ho)_MinimalGlucose</th>\n",
       "      <th>WT(ho)_Proline</th>\n",
       "      <th>WT(ho)_Urea</th>\n",
       "      <th>WT(ho)_YPD</th>\n",
       "      <th>WT(ho)_YPDDiauxic</th>\n",
       "      <th>WT(ho)_YPDRapa</th>\n",
       "      <th>...</th>\n",
       "      <th>stp2_CStarve</th>\n",
       "      <th>stp2_Glutamine</th>\n",
       "      <th>stp2_MinimalEtOH</th>\n",
       "      <th>stp2_MinimalGlucose</th>\n",
       "      <th>stp2_Proline</th>\n",
       "      <th>stp2_Urea</th>\n",
       "      <th>stp2_YPD</th>\n",
       "      <th>stp2_YPDDiauxic</th>\n",
       "      <th>stp2_YPDRapa</th>\n",
       "      <th>stp2_YPEtOH</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>YDL248W</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004902</td>\n",
       "      <td>0.015385</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.003185</td>\n",
       "      <td>0.002146</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004049</td>\n",
       "      <td>0.009901</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.006515</td>\n",
       "      <td>0.00375</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL247W.A</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL247W</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL246C</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL245C</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004184</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.002146</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.017857</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00125</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q0275</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.004902</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.003185</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.006515</td>\n",
       "      <td>0.00125</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>RPM1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q0297</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.00000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KANMX</th>\n",
       "      <td>9.595041</td>\n",
       "      <td>1.757322</td>\n",
       "      <td>6.472973</td>\n",
       "      <td>4.807692</td>\n",
       "      <td>8.029412</td>\n",
       "      <td>2.553846</td>\n",
       "      <td>10.333333</td>\n",
       "      <td>5.694672</td>\n",
       "      <td>3.420382</td>\n",
       "      <td>3.290773</td>\n",
       "      <td>...</td>\n",
       "      <td>1.721973</td>\n",
       "      <td>6.639752</td>\n",
       "      <td>8.089286</td>\n",
       "      <td>9.728745</td>\n",
       "      <td>3.485149</td>\n",
       "      <td>12.678261</td>\n",
       "      <td>6.365729</td>\n",
       "      <td>3.296417</td>\n",
       "      <td>3.77375</td>\n",
       "      <td>10.099291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NATMX</th>\n",
       "      <td>12.314050</td>\n",
       "      <td>2.891213</td>\n",
       "      <td>15.229730</td>\n",
       "      <td>6.230769</td>\n",
       "      <td>18.808824</td>\n",
       "      <td>4.800000</td>\n",
       "      <td>13.292517</td>\n",
       "      <td>21.161885</td>\n",
       "      <td>6.041401</td>\n",
       "      <td>16.136266</td>\n",
       "      <td>...</td>\n",
       "      <td>2.834081</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>8.660714</td>\n",
       "      <td>23.226721</td>\n",
       "      <td>4.772277</td>\n",
       "      <td>16.147826</td>\n",
       "      <td>25.069054</td>\n",
       "      <td>6.495114</td>\n",
       "      <td>20.48125</td>\n",
       "      <td>19.397163</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6829 rows × 132 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "sample     WT(ho)_AmmoniumSulfate  WT(ho)_CStarve  WT(ho)_Glutamine  \\\n",
       "YDL248W                  0.000000        0.000000          0.000000   \n",
       "YDL247W.A                0.000000        0.000000          0.000000   \n",
       "YDL247W                  0.000000        0.000000          0.000000   \n",
       "YDL246C                  0.000000        0.000000          0.000000   \n",
       "YDL245C                  0.000000        0.004184          0.000000   \n",
       "...                           ...             ...               ...   \n",
       "Q0275                    0.000000        0.000000          0.000000   \n",
       "RPM1                     0.000000        0.000000          0.000000   \n",
       "Q0297                    0.000000        0.000000          0.000000   \n",
       "KANMX                    9.595041        1.757322          6.472973   \n",
       "NATMX                   12.314050        2.891213         15.229730   \n",
       "\n",
       "sample     WT(ho)_MinimalEtOH  WT(ho)_MinimalGlucose  WT(ho)_Proline  \\\n",
       "YDL248W              0.000000               0.004902        0.015385   \n",
       "YDL247W.A            0.000000               0.000000        0.000000   \n",
       "YDL247W              0.000000               0.000000        0.000000   \n",
       "YDL246C              0.000000               0.000000        0.000000   \n",
       "YDL245C              0.000000               0.000000        0.000000   \n",
       "...                       ...                    ...             ...   \n",
       "Q0275                0.000000               0.004902        0.000000   \n",
       "RPM1                 0.000000               0.000000        0.000000   \n",
       "Q0297                0.000000               0.000000        0.000000   \n",
       "KANMX                4.807692               8.029412        2.553846   \n",
       "NATMX                6.230769              18.808824        4.800000   \n",
       "\n",
       "sample     WT(ho)_Urea  WT(ho)_YPD  WT(ho)_YPDDiauxic  WT(ho)_YPDRapa  ...  \\\n",
       "YDL248W       0.000000    0.000000           0.003185        0.002146  ...   \n",
       "YDL247W.A     0.000000    0.000000           0.000000        0.000000  ...   \n",
       "YDL247W       0.000000    0.000000           0.000000        0.000000  ...   \n",
       "YDL246C       0.000000    0.000000           0.000000        0.000000  ...   \n",
       "YDL245C       0.000000    0.000000           0.000000        0.002146  ...   \n",
       "...                ...         ...                ...             ...  ...   \n",
       "Q0275         0.000000    0.000000           0.003185        0.000000  ...   \n",
       "RPM1          0.000000    0.000000           0.000000        0.000000  ...   \n",
       "Q0297         0.000000    0.000000           0.000000        0.000000  ...   \n",
       "KANMX        10.333333    5.694672           3.420382        3.290773  ...   \n",
       "NATMX        13.292517   21.161885           6.041401       16.136266  ...   \n",
       "\n",
       "sample     stp2_CStarve  stp2_Glutamine  stp2_MinimalEtOH  \\\n",
       "YDL248W        0.000000        0.000000          0.000000   \n",
       "YDL247W.A      0.000000        0.000000          0.000000   \n",
       "YDL247W        0.000000        0.000000          0.000000   \n",
       "YDL246C        0.000000        0.000000          0.000000   \n",
       "YDL245C        0.000000        0.000000          0.017857   \n",
       "...                 ...             ...               ...   \n",
       "Q0275          0.000000        0.000000          0.000000   \n",
       "RPM1           0.000000        0.000000          0.000000   \n",
       "Q0297          0.000000        0.000000          0.000000   \n",
       "KANMX          1.721973        6.639752          8.089286   \n",
       "NATMX          2.834081       15.000000          8.660714   \n",
       "\n",
       "sample     stp2_MinimalGlucose  stp2_Proline  stp2_Urea   stp2_YPD  \\\n",
       "YDL248W               0.004049      0.009901   0.000000   0.000000   \n",
       "YDL247W.A             0.000000      0.000000   0.000000   0.000000   \n",
       "YDL247W               0.000000      0.000000   0.000000   0.000000   \n",
       "YDL246C               0.000000      0.000000   0.000000   0.000000   \n",
       "YDL245C               0.000000      0.000000   0.000000   0.000000   \n",
       "...                        ...           ...        ...        ...   \n",
       "Q0275                 0.000000      0.000000   0.000000   0.000000   \n",
       "RPM1                  0.000000      0.000000   0.000000   0.000000   \n",
       "Q0297                 0.000000      0.000000   0.000000   0.000000   \n",
       "KANMX                 9.728745      3.485149  12.678261   6.365729   \n",
       "NATMX                23.226721      4.772277  16.147826  25.069054   \n",
       "\n",
       "sample     stp2_YPDDiauxic  stp2_YPDRapa  stp2_YPEtOH  \n",
       "YDL248W           0.006515       0.00375     0.000000  \n",
       "YDL247W.A         0.000000       0.00000     0.000000  \n",
       "YDL247W           0.000000       0.00000     0.000000  \n",
       "YDL246C           0.000000       0.00000     0.000000  \n",
       "YDL245C           0.000000       0.00125     0.000000  \n",
       "...                    ...           ...          ...  \n",
       "Q0275             0.006515       0.00125     0.000000  \n",
       "RPM1              0.000000       0.00000     0.000000  \n",
       "Q0297             0.000000       0.00000     0.000000  \n",
       "KANMX             3.296417       3.77375    10.099291  \n",
       "NATMX             6.495114      20.48125    19.397163  \n",
       "\n",
       "[6829 rows x 132 columns]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pseudobulk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(6520, 132)"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Remove all zero genes\n",
    "pseudobulk_nonzero = pseudobulk.loc[pseudobulk.sum(axis=1) > 0]\n",
    "pseudobulk_nonzero.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 6520 genes that have at least one count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5804, 132)"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Remove genes with more than 80% of zeros\n",
    "perc = 0.2\n",
    "pseudobulk_perc = pseudobulk.loc[(pseudobulk>0).sum(axis=1) > (perc*pseudobulk.shape[1])]\n",
    "pseudobulk_perc.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 5804 genes that have a non-zero value in at least 20% of samples. \n",
    "We remove samples that have zero counts in more than 80% of samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 0\n"
     ]
    }
   ],
   "source": [
    "print(\n",
    "    (pseudobulk_perc.sum(axis = 0)==0).sum(), \n",
    "    (pseudobulk_nonzero.sum(axis = 0)==0).sum())\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are no samples that have all genes non-expressed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Let's log and save\n",
    "pseudobulk_nonzero_log = np.log(pseudobulk_nonzero+1)\n",
    "pseudobulk_nonzero_log.to_csv('../data/processed/pseudobulk_nonzero_logcounts.tsv', sep = '\\t')\n",
    "\n",
    "pseudobulk_perc_log = np.log(pseudobulk_perc+1)\n",
    "pseudobulk_perc_log.to_csv('../data/processed/pseudobulk_perc02_logcounts.tsv', sep = '\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'nonzero': {'yeast_expression': '../data/processed/pseudobulk_nonzero_logcounts.tsv',\n",
       "  'output_folder': '../results/new_pseudobulk_nonzero/'},\n",
       " 'perc02': {'yeast_expression': '../data/processed/pseudobulk_perc02_logcounts.tsv',\n",
       "  'output_folder': '../results/new_pseudobulk_perc02/'}}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Cleaned and pseudobulked data\n",
    "params = {\n",
    "    'nonzero' : {'yeast_expression' : '../data/processed/pseudobulk_nonzero_logcounts.tsv',\\\n",
    "               'output_folder' : '../results/new_pseudobulk_nonzero/'},\\\n",
    "    'perc02' : {'yeast_expression': '../data/processed/pseudobulk_perc02_logcounts.tsv',\\\n",
    "              'output_folder' : '../results/new_pseudobulk_perc02/'}\n",
    "}\n",
    "params"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Choose dataset of interest between nonzero and perc02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "choice = 'nonzero'\n",
    "#choice = 'perc02'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compute the networks\n",
    "\n",
    "BONOBO can be simply computed by first instantiating the Bonobo class, and then calling the run_bonobo method.\n",
    "\n",
    "Below is the example on how these networks have been generated"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Output folder exists:../results/new_pseudobulk_nonzero/\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "yeast_expression = params[choice]['yeast_expression']\n",
    "output_folder = params[choice]['output_folder']\n",
    "if os.path.exists(output_folder) == False:\n",
    "    os.makedirs(output_folder)\n",
    "    print('Created output folder:%s' %output_folder)\n",
    "else:\n",
    "    print('Output folder exists:%s' %output_folder)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0, 132)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_samples = pd.read_csv(yeast_expression, nrows = 3, sep = '\\t', index_col=0).columns.tolist()\n",
    "done_bonobo = [i.split('/')[-1][7:-3] for i in  glob.glob(output_folder + 'bonobo/bonobo*.h5')]\n",
    "\n",
    "left = list(set(all_samples) - set(done_bonobo))\n",
    "len(left), len(done_bonobo)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['WT(ho)_AmmoniumSulfate',\n",
       " 'WT(ho)_CStarve',\n",
       " 'WT(ho)_Glutamine',\n",
       " 'WT(ho)_MinimalEtOH',\n",
       " 'WT(ho)_MinimalGlucose',\n",
       " 'WT(ho)_Proline',\n",
       " 'WT(ho)_Urea',\n",
       " 'WT(ho)_YPD',\n",
       " 'WT(ho)_YPDDiauxic',\n",
       " 'WT(ho)_YPDRapa',\n",
       " 'WT(ho)_YPEtOH',\n",
       " 'dal80_AmmoniumSulfate',\n",
       " 'dal80_CStarve',\n",
       " 'dal80_Glutamine',\n",
       " 'dal80_MinimalEtOH',\n",
       " 'dal80_MinimalGlucose',\n",
       " 'dal80_Proline',\n",
       " 'dal80_Urea',\n",
       " 'dal80_YPD',\n",
       " 'dal80_YPDDiauxic',\n",
       " 'dal80_YPDRapa',\n",
       " 'dal80_YPEtOH',\n",
       " 'dal81_AmmoniumSulfate',\n",
       " 'dal81_CStarve',\n",
       " 'dal81_Glutamine',\n",
       " 'dal81_MinimalEtOH',\n",
       " 'dal81_MinimalGlucose',\n",
       " 'dal81_Proline',\n",
       " 'dal81_Urea',\n",
       " 'dal81_YPD',\n",
       " 'dal81_YPDDiauxic',\n",
       " 'dal81_YPDRapa',\n",
       " 'dal81_YPEtOH',\n",
       " 'dal82_AmmoniumSulfate',\n",
       " 'dal82_CStarve',\n",
       " 'dal82_Glutamine',\n",
       " 'dal82_MinimalEtOH',\n",
       " 'dal82_MinimalGlucose',\n",
       " 'dal82_Proline',\n",
       " 'dal82_Urea',\n",
       " 'dal82_YPD',\n",
       " 'dal82_YPDDiauxic',\n",
       " 'dal82_YPDRapa',\n",
       " 'dal82_YPEtOH',\n",
       " 'gat1_AmmoniumSulfate',\n",
       " 'gat1_CStarve',\n",
       " 'gat1_Glutamine',\n",
       " 'gat1_MinimalEtOH',\n",
       " 'gat1_MinimalGlucose',\n",
       " 'gat1_Proline',\n",
       " 'gat1_Urea',\n",
       " 'gat1_YPD',\n",
       " 'gat1_YPDDiauxic',\n",
       " 'gat1_YPDRapa',\n",
       " 'gat1_YPEtOH',\n",
       " 'gcn4_AmmoniumSulfate',\n",
       " 'gcn4_CStarve',\n",
       " 'gcn4_Glutamine',\n",
       " 'gcn4_MinimalEtOH',\n",
       " 'gcn4_MinimalGlucose',\n",
       " 'gcn4_Proline',\n",
       " 'gcn4_Urea',\n",
       " 'gcn4_YPD',\n",
       " 'gcn4_YPDDiauxic',\n",
       " 'gcn4_YPDRapa',\n",
       " 'gcn4_YPEtOH',\n",
       " 'gln3_AmmoniumSulfate',\n",
       " 'gln3_CStarve',\n",
       " 'gln3_Glutamine',\n",
       " 'gln3_MinimalEtOH',\n",
       " 'gln3_MinimalGlucose',\n",
       " 'gln3_Proline',\n",
       " 'gln3_Urea',\n",
       " 'gln3_YPD',\n",
       " 'gln3_YPDDiauxic',\n",
       " 'gln3_YPDRapa',\n",
       " 'gln3_YPEtOH',\n",
       " 'gzf3_AmmoniumSulfate',\n",
       " 'gzf3_CStarve',\n",
       " 'gzf3_Glutamine',\n",
       " 'gzf3_MinimalEtOH',\n",
       " 'gzf3_MinimalGlucose',\n",
       " 'gzf3_Proline',\n",
       " 'gzf3_Urea',\n",
       " 'gzf3_YPD',\n",
       " 'gzf3_YPDDiauxic',\n",
       " 'gzf3_YPDRapa',\n",
       " 'gzf3_YPEtOH',\n",
       " 'rtg1_AmmoniumSulfate',\n",
       " 'rtg1_CStarve',\n",
       " 'rtg1_Glutamine',\n",
       " 'rtg1_MinimalEtOH',\n",
       " 'rtg1_MinimalGlucose',\n",
       " 'rtg1_Proline',\n",
       " 'rtg1_Urea',\n",
       " 'rtg1_YPD',\n",
       " 'rtg1_YPDDiauxic',\n",
       " 'rtg1_YPDRapa',\n",
       " 'rtg1_YPEtOH',\n",
       " 'rtg3_AmmoniumSulfate',\n",
       " 'rtg3_CStarve',\n",
       " 'rtg3_Glutamine',\n",
       " 'rtg3_MinimalEtOH',\n",
       " 'rtg3_MinimalGlucose',\n",
       " 'rtg3_Proline',\n",
       " 'rtg3_Urea',\n",
       " 'rtg3_YPD',\n",
       " 'rtg3_YPDDiauxic',\n",
       " 'rtg3_YPDRapa',\n",
       " 'rtg3_YPEtOH',\n",
       " 'stp1_AmmoniumSulfate',\n",
       " 'stp1_CStarve',\n",
       " 'stp1_Glutamine',\n",
       " 'stp1_MinimalEtOH',\n",
       " 'stp1_MinimalGlucose',\n",
       " 'stp1_Proline',\n",
       " 'stp1_Urea',\n",
       " 'stp1_YPD',\n",
       " 'stp1_YPDDiauxic',\n",
       " 'stp1_YPDRapa',\n",
       " 'stp1_YPEtOH',\n",
       " 'stp2_AmmoniumSulfate',\n",
       " 'stp2_CStarve',\n",
       " 'stp2_Glutamine',\n",
       " 'stp2_MinimalEtOH',\n",
       " 'stp2_MinimalGlucose',\n",
       " 'stp2_Proline',\n",
       " 'stp2_Urea',\n",
       " 'stp2_YPD',\n",
       " 'stp2_YPDDiauxic',\n",
       " 'stp2_YPDRapa',\n",
       " 'stp2_YPEtOH']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all_samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BONOBO: preparing expression\n",
      "Reading expression data...\n",
      "None\n",
      "  Elapsed time: 0.08 sec.\n",
      "BONOBO: We are starting to compute the bonobos...\n",
      "BONOBO: bonobo for sample gzf3_YPEtOH\n",
      "BONOBO: computing bonobo for sample gzf3_YPEtOH\n",
      "keep Bonobo whole, and use pvals to threshold and sparsify\n",
      "Saving BONOBO for sample gzf3_YPEtOH\n",
      "WARNING: output format (h5) not recognised. We are saving in hdf\n",
      "Saving pvalues for sample gzf3_YPEtOH\n",
      "WARNING: output format (h5) not recognised. We are saving in hdf\n"
     ]
    }
   ],
   "source": [
    "from netZooPy.bonobo.bonobo import Bonobo\n",
    "\n",
    "# Initialize bonobo object\n",
    "bonobo_obj_sparse = Bonobo(yeast_expression)\n",
    "# If you want to run bonobo with a subset of the data, you can specify the sample names and pass them to the run_bonobo\n",
    "# method. In this case we are using all samples\n",
    "#sample_names=['WT(ho)_AmmoniumSulfate','WT(ho)_CStarve','WT(ho)_Glutamine']\n",
    "#sample_names = left\n",
    "# Run the actual bonobo computation. \n",
    "\n",
    "# We cannot keep all the data in memory in this case, these networks are too large: keep_in_memory=False\n",
    "# We will save the p-values for the edges in the output_folder: sparsify=True, save_pvals=True\n",
    "# The output format is hd5, which is the most efficient way to store the data on disk, output_fmt='hd5'\n",
    "bonobo_obj_sparse.run_bonobo(keep_in_memory=False, output_fmt='h5', sparsify=True, output_folder=output_folder+'bonobo/', save_pvals=True, sample_names=['gzf3_YPEtOH'])\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Get the BONOBO networks for the analysis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "def get_bonobo_dataframe(nets_fn, pvals_prefix = None, strategy = 'sparse', pth = 0.1, nk=1000, gene = 'YEL009C'):\n",
    "\n",
    "    df_bonobos = pd.DataFrame()\n",
    "\n",
    "    for iii,bbb in enumerate(nets_fn):\n",
    "        if iii>-1:\n",
    "            k = bbb.split('/')[-1][:-3][7:]\n",
    "            temp = pd.read_hdf(bbb)\n",
    "                \n",
    "            temp.index = temp.columns\n",
    "            # Upper triangular matrix\n",
    "            temp = temp.where(np.triu(np.ones(temp.shape), k = 1).astype(bool))\n",
    "            # Put in long format\n",
    "            temp = temp.stack().reset_index() \n",
    "            # Rename columns\n",
    "            temp.columns = ['gene1','gene2',k]\n",
    "            \n",
    "            if strategy == 'sparse':\n",
    "                \n",
    "                print(pvals_prefix + k + '.h5')\n",
    "                assert os.path.isfile(pvals_prefix + k + '.h5'), 'pvals file not found'\n",
    "                pvals_fn = pvals_prefix + k + '.h5'\n",
    "                pvals = pd.read_hdf(pvals_fn)\n",
    "                pvals = pvals.where(np.triu(np.ones(pvals.shape), k = 1).astype(bool))\n",
    "                pvals = pvals.stack().reset_index() \n",
    "                \n",
    "                ps = pvals.iloc[:,2].values\n",
    "                \n",
    "                temp = temp[ps<pth]\n",
    "\n",
    "                if iii== 0:\n",
    "                    df_bonobos = temp\n",
    "                else:\n",
    "                    df_bonobos = pd.merge(df_bonobos, temp, how = 'outer', on = ['gene1','gene2'])\n",
    "                    \n",
    "            elif strategy == 'random':\n",
    "                if iii==0:\n",
    "                    print(k)\n",
    "                    print(nk)\n",
    "                    index_random = np.random.choice(np.arange(len(temp.index)), nk, replace = False)\n",
    "                    df_bonobos = temp.iloc[index_random,:]\n",
    "                    \n",
    "                else:\n",
    "                    #df_bonobos[k] = temp.iloc[index_random,:][k]\n",
    "                    df_bonobos = pd.concat([df_bonobos, temp.iloc[index_random,:][k]], axis = 1)\n",
    "                    \n",
    "            elif strategy == 'gene':\n",
    "                # Get only one gene\n",
    "                if iii == 0:\n",
    "                    df_bonobos = temp[(temp['gene1'] == gene) | (temp['gene2'] == gene)]\n",
    "                else:\n",
    "                    df_bonobos = pd.concat([df_bonobos, temp[(temp['gene1'] == gene) | (temp['gene2'] == gene)][k]], axis = 1)\n",
    "                    \n",
    "            else:\n",
    "                if iii == 0:\n",
    "                    df_bonobos = temp\n",
    "                else:\n",
    "                    #df_bonobos[k] = temp[k]\n",
    "                    df_bonobos = pd.concat([df_bonobos, temp[k]], axis = 1)\n",
    "            \n",
    "\n",
    "    return(df_bonobos)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "def get_gene_bonobo_dataframe(nets_fn, gene = 'YEL009C'):\n",
    "\n",
    "    df_bonobos = pd.DataFrame()\n",
    "\n",
    "    for iii,bbb in enumerate(nets_fn):\n",
    "        if iii>-1:\n",
    "            k = bbb.split('/')[-1][:-3][7:]\n",
    "            temp = pd.read_hdf(bbb)\n",
    "                \n",
    "            temp.index = temp.columns\n",
    "            \n",
    "            temp = temp.loc[:,[gene]]\n",
    "        \n",
    "            temp['gene1'] = temp.index\n",
    "            temp['gene2'] = gene\n",
    "            temp[k] = temp.loc[:,[gene]]\n",
    "            temp = temp.loc[:,['gene1','gene2',k]]\n",
    "            \n",
    "            if iii == 0:\n",
    "                df_bonobos = temp\n",
    "            else:\n",
    "                df_bonobos = pd.concat([df_bonobos, temp.loc[:,k]], axis = 1)\n",
    "\n",
    "    return(df_bonobos)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### BONOBO sparse\n",
    "\n",
    "Here you should change the paths depending on where you want to save the data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp2_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_MinimalEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_AmmoniumSulfate.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_YPD.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_stp1_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gat1_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gzf3_Proline.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_WT(ho)_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal80_YPEtOH.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_CStarve.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gln3_YPDRapa.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg3_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_gcn4_YPDDiauxic.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal81_Urea.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_Glutamine.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_rtg1_MinimalGlucose.h5',\n",
       " '../results/new_pseudobulk_nonzero/bonobo/bonobo_dal82_YPD.h5']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import glob\n",
    "#nets_fn = glob.glob('bonobo_inferelator_sparse_20230908/bonobo*.h5')\n",
    "#pvals_prefix = ('bonobo_inferelator_sparse_20230908/pvals_')\n",
    "\n",
    "nets_fn = glob.glob(output_folder+'bonobo/bonobo*.h5')\n",
    "pvals_prefix = (output_folder+'bonobo/pvals_')\n",
    "\n",
    "nets_fn\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp2_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_YPD.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_stp1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gat1_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gzf3_Proline.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_WT(ho)_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal80_YPEtOH.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_CStarve.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gln3_YPDRapa.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg3_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_gcn4_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal81_Urea.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_Glutamine.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_rtg1_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_nonzero/bonobo/pvals_dal82_YPD.h5\n"
     ]
    }
   ],
   "source": [
    "bonobo_sparse = get_bonobo_dataframe(nets_fn, pvals_prefix = pvals_prefix, strategy = 'sparse', pth=0.01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "bonobo_sparse.to_hdf(output_folder+'bonobo_sparse_001.h5', key='bonobo_sparse', mode='w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#import os\n",
    "#if os.path.isdir('data/networks/bonobo/') == False:\n",
    "#    os.mkdir('data/networks/bonobo/')\n",
    "#bonobo_sparse.to_csv('data/networks/bonobo/bonobo_sparse.csv', index = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### BONOBO th005"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_MinimalGlucose.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal82_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp2_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_Urea.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_MinimalEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gln3_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_AmmoniumSulfate.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_YPD.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_stp1_YPDDiauxic.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal81_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_YPDRapa.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gcn4_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gat1_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_gzf3_Proline.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_WT(ho)_Glutamine.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_dal80_YPEtOH.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg1_CStarve.h5\n",
      "../results/new_pseudobulk_perc02/bonobo/pvals_rtg3_YPDRapa.h5\n"
     ]
    }
   ],
   "source": [
    "bonobo_sparse = get_bonobo_dataframe(nets_fn, pvals_prefix = pvals_prefix, strategy = 'sparse', pth=0.05)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bonobo_sparse.to_hdf(output_folder+'bonobo_sparse_005.h5', key='bonobo_sparse', mode='w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp2_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_MinimalEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_AmmoniumSulfate.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_YPD.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_stp1_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gat1_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gzf3_Proline.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_WT(ho)_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal80_YPEtOH.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_CStarve.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gln3_YPDRapa.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg3_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_gcn4_YPDDiauxic.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal81_Urea.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_Glutamine.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_rtg1_MinimalGlucose.h5\n",
      "../results/pseudobulk_nonzero/bonobo/pvals_dal82_YPD.h5\n"
     ]
    }
   ],
   "source": [
    "#bonobo_sparse = get_bonobo_dataframe(nets_fn, pvals_prefix = pvals_prefix, strategy = 'sparse', pth=0.1)\n",
    "#bonobo_sparse.to_hdf(output_folder+'bonobo_sparse_01.h5', key='bonobo_sparse', mode='w')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### BONOBO top1k"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#df_all = get_bonobo_dataframe(nets_fn[:3], strategy = 'all')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#df_all.to_hdf(output_folder+'bonobo_all.h5', key='bonobo', mode='w')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# df_all.columns =[i[7:] if i.startswith('bonobo') else i for i in df_all.columns]\n",
    "# # Get top 1k edges\n",
    "# mean = df_all.iloc[:,2:].mean(axis = 1)\n",
    "# mean.sort_values(ascending = False, inplace = True)\n",
    "# # Get top 1K\n",
    "# top_1k = np.r_[mean.index.values[:500], mean.index.values[-500:]]\n",
    "# df_top1k = df_all.iloc[top_1k, :]\n",
    "# #df_top1k\n",
    "# #if os.path.isdir('data/networks/bonobo/') == False:\n",
    "# #    os.mkdir('data/networks/bonobo/')\n",
    "# df_top1k.to_csv(output_folder+'bonobo_top1k.csv', index = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Random "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dal82_MinimalGlucose\n",
      "1000\n"
     ]
    }
   ],
   "source": [
    "df_random_1k = get_bonobo_dataframe(nets_fn, strategy = 'random', nk = 1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "#random_1k = np.random.choice(df_all.index, 1000, replace = False)\n",
    "#df_random_1k = df_all.loc[random_1k, :]\n",
    "df_random_1k.to_csv(output_folder+'bonobo_random1k.csv', index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene1</th>\n",
       "      <th>gene2</th>\n",
       "      <th>dal82_MinimalGlucose</th>\n",
       "      <th>dal81_YPDDiauxic</th>\n",
       "      <th>gln3_YPD</th>\n",
       "      <th>stp1_YPDRapa</th>\n",
       "      <th>dal81_MinimalEtOH</th>\n",
       "      <th>dal82_YPDDiauxic</th>\n",
       "      <th>WT(ho)_YPDRapa</th>\n",
       "      <th>gat1_YPD</th>\n",
       "      <th>...</th>\n",
       "      <th>dal80_YPEtOH</th>\n",
       "      <th>rtg1_CStarve</th>\n",
       "      <th>rtg3_YPDRapa</th>\n",
       "      <th>gln3_YPDRapa</th>\n",
       "      <th>rtg3_Urea</th>\n",
       "      <th>gcn4_YPDDiauxic</th>\n",
       "      <th>dal81_Urea</th>\n",
       "      <th>rtg1_Glutamine</th>\n",
       "      <th>rtg1_MinimalGlucose</th>\n",
       "      <th>dal82_YPD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3959733</th>\n",
       "      <td>YDR525W.A</td>\n",
       "      <td>YCR105W</td>\n",
       "      <td>0.437001</td>\n",
       "      <td>0.423773</td>\n",
       "      <td>0.456187</td>\n",
       "      <td>0.442464</td>\n",
       "      <td>0.420573</td>\n",
       "      <td>0.448846</td>\n",
       "      <td>0.423015</td>\n",
       "      <td>0.436674</td>\n",
       "      <td>...</td>\n",
       "      <td>0.462554</td>\n",
       "      <td>0.422464</td>\n",
       "      <td>0.435829</td>\n",
       "      <td>0.442340</td>\n",
       "      <td>0.420541</td>\n",
       "      <td>0.455527</td>\n",
       "      <td>0.440694</td>\n",
       "      <td>0.457051</td>\n",
       "      <td>0.453254</td>\n",
       "      <td>0.419872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1155468</th>\n",
       "      <td>YDL030W</td>\n",
       "      <td>YNL164C</td>\n",
       "      <td>0.238048</td>\n",
       "      <td>0.224901</td>\n",
       "      <td>0.254001</td>\n",
       "      <td>0.243356</td>\n",
       "      <td>0.290020</td>\n",
       "      <td>0.234187</td>\n",
       "      <td>0.246233</td>\n",
       "      <td>0.244152</td>\n",
       "      <td>...</td>\n",
       "      <td>0.252488</td>\n",
       "      <td>0.252090</td>\n",
       "      <td>0.244590</td>\n",
       "      <td>0.231848</td>\n",
       "      <td>0.238815</td>\n",
       "      <td>0.259005</td>\n",
       "      <td>0.223404</td>\n",
       "      <td>0.237021</td>\n",
       "      <td>0.200676</td>\n",
       "      <td>0.245670</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15868129</th>\n",
       "      <td>YKL152C</td>\n",
       "      <td>YKL012W</td>\n",
       "      <td>-0.160357</td>\n",
       "      <td>-0.168591</td>\n",
       "      <td>-0.211707</td>\n",
       "      <td>-0.152905</td>\n",
       "      <td>-0.230486</td>\n",
       "      <td>-0.185077</td>\n",
       "      <td>-0.181239</td>\n",
       "      <td>-0.203021</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.224674</td>\n",
       "      <td>-0.145569</td>\n",
       "      <td>-0.173586</td>\n",
       "      <td>-0.186482</td>\n",
       "      <td>-0.178214</td>\n",
       "      <td>-0.188925</td>\n",
       "      <td>-0.185918</td>\n",
       "      <td>-0.123766</td>\n",
       "      <td>-0.177847</td>\n",
       "      <td>-0.202909</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3019239</th>\n",
       "      <td>YDR332W</td>\n",
       "      <td>YIR008C</td>\n",
       "      <td>0.401581</td>\n",
       "      <td>0.405877</td>\n",
       "      <td>0.410066</td>\n",
       "      <td>0.421252</td>\n",
       "      <td>0.363763</td>\n",
       "      <td>0.406276</td>\n",
       "      <td>0.405590</td>\n",
       "      <td>0.405143</td>\n",
       "      <td>...</td>\n",
       "      <td>0.387864</td>\n",
       "      <td>0.411548</td>\n",
       "      <td>0.409003</td>\n",
       "      <td>0.406112</td>\n",
       "      <td>0.414925</td>\n",
       "      <td>0.347930</td>\n",
       "      <td>0.425920</td>\n",
       "      <td>0.389254</td>\n",
       "      <td>0.442493</td>\n",
       "      <td>0.410184</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3073616</th>\n",
       "      <td>YDR345C</td>\n",
       "      <td>YLR147C</td>\n",
       "      <td>-0.162769</td>\n",
       "      <td>-0.258849</td>\n",
       "      <td>-0.205507</td>\n",
       "      <td>-0.207154</td>\n",
       "      <td>-0.250811</td>\n",
       "      <td>-0.255881</td>\n",
       "      <td>-0.201851</td>\n",
       "      <td>-0.210255</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.245164</td>\n",
       "      <td>-0.165162</td>\n",
       "      <td>-0.200771</td>\n",
       "      <td>-0.208196</td>\n",
       "      <td>-0.238111</td>\n",
       "      <td>-0.226597</td>\n",
       "      <td>-0.180216</td>\n",
       "      <td>-0.188619</td>\n",
       "      <td>-0.210292</td>\n",
       "      <td>-0.211100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3743583</th>\n",
       "      <td>YDR480W</td>\n",
       "      <td>YBR177C</td>\n",
       "      <td>0.293807</td>\n",
       "      <td>0.314196</td>\n",
       "      <td>0.322778</td>\n",
       "      <td>0.307786</td>\n",
       "      <td>0.314589</td>\n",
       "      <td>0.303186</td>\n",
       "      <td>0.300816</td>\n",
       "      <td>0.321936</td>\n",
       "      <td>...</td>\n",
       "      <td>0.296849</td>\n",
       "      <td>0.326275</td>\n",
       "      <td>0.308896</td>\n",
       "      <td>0.304540</td>\n",
       "      <td>0.241789</td>\n",
       "      <td>0.304318</td>\n",
       "      <td>0.310999</td>\n",
       "      <td>0.294238</td>\n",
       "      <td>0.308701</td>\n",
       "      <td>0.322012</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12716752</th>\n",
       "      <td>YMR055C</td>\n",
       "      <td>YHR007C.A</td>\n",
       "      <td>-0.026557</td>\n",
       "      <td>0.006939</td>\n",
       "      <td>0.007400</td>\n",
       "      <td>-0.013815</td>\n",
       "      <td>0.020399</td>\n",
       "      <td>-0.005707</td>\n",
       "      <td>-0.009489</td>\n",
       "      <td>0.001280</td>\n",
       "      <td>...</td>\n",
       "      <td>0.105331</td>\n",
       "      <td>0.009857</td>\n",
       "      <td>-0.011334</td>\n",
       "      <td>-0.002719</td>\n",
       "      <td>0.020440</td>\n",
       "      <td>-0.057969</td>\n",
       "      <td>0.020371</td>\n",
       "      <td>-0.001444</td>\n",
       "      <td>0.007230</td>\n",
       "      <td>-0.003173</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7373832</th>\n",
       "      <td>YGL062W</td>\n",
       "      <td>YML122C</td>\n",
       "      <td>0.015821</td>\n",
       "      <td>0.071242</td>\n",
       "      <td>0.031423</td>\n",
       "      <td>0.012354</td>\n",
       "      <td>0.005661</td>\n",
       "      <td>0.017594</td>\n",
       "      <td>0.009611</td>\n",
       "      <td>0.026277</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.015209</td>\n",
       "      <td>0.028969</td>\n",
       "      <td>0.015254</td>\n",
       "      <td>0.014853</td>\n",
       "      <td>0.030025</td>\n",
       "      <td>0.073373</td>\n",
       "      <td>0.029154</td>\n",
       "      <td>0.011944</td>\n",
       "      <td>0.023508</td>\n",
       "      <td>0.028704</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9799516</th>\n",
       "      <td>YLR210W</td>\n",
       "      <td>YFR003C</td>\n",
       "      <td>0.113139</td>\n",
       "      <td>0.107818</td>\n",
       "      <td>0.107481</td>\n",
       "      <td>0.092703</td>\n",
       "      <td>0.148317</td>\n",
       "      <td>0.092146</td>\n",
       "      <td>0.076100</td>\n",
       "      <td>0.121516</td>\n",
       "      <td>...</td>\n",
       "      <td>0.104341</td>\n",
       "      <td>0.135002</td>\n",
       "      <td>0.065076</td>\n",
       "      <td>0.059805</td>\n",
       "      <td>0.143311</td>\n",
       "      <td>0.111416</td>\n",
       "      <td>0.154097</td>\n",
       "      <td>0.089413</td>\n",
       "      <td>0.105142</td>\n",
       "      <td>0.116481</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2246794</th>\n",
       "      <td>YDR177W</td>\n",
       "      <td>Q0110</td>\n",
       "      <td>0.473640</td>\n",
       "      <td>0.461481</td>\n",
       "      <td>0.488671</td>\n",
       "      <td>0.489795</td>\n",
       "      <td>0.457115</td>\n",
       "      <td>0.495034</td>\n",
       "      <td>0.490528</td>\n",
       "      <td>0.485176</td>\n",
       "      <td>...</td>\n",
       "      <td>0.495131</td>\n",
       "      <td>0.494034</td>\n",
       "      <td>0.494767</td>\n",
       "      <td>0.487180</td>\n",
       "      <td>0.495261</td>\n",
       "      <td>0.467383</td>\n",
       "      <td>0.494825</td>\n",
       "      <td>0.487545</td>\n",
       "      <td>0.470948</td>\n",
       "      <td>0.478588</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 134 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "              gene1      gene2  dal82_MinimalGlucose  dal81_YPDDiauxic  \\\n",
       "3959733   YDR525W.A    YCR105W              0.437001          0.423773   \n",
       "1155468     YDL030W    YNL164C              0.238048          0.224901   \n",
       "15868129    YKL152C    YKL012W             -0.160357         -0.168591   \n",
       "3019239     YDR332W    YIR008C              0.401581          0.405877   \n",
       "3073616     YDR345C    YLR147C             -0.162769         -0.258849   \n",
       "...             ...        ...                   ...               ...   \n",
       "3743583     YDR480W    YBR177C              0.293807          0.314196   \n",
       "12716752    YMR055C  YHR007C.A             -0.026557          0.006939   \n",
       "7373832     YGL062W    YML122C              0.015821          0.071242   \n",
       "9799516     YLR210W    YFR003C              0.113139          0.107818   \n",
       "2246794     YDR177W      Q0110              0.473640          0.461481   \n",
       "\n",
       "          gln3_YPD  stp1_YPDRapa  dal81_MinimalEtOH  dal82_YPDDiauxic  \\\n",
       "3959733   0.456187      0.442464           0.420573          0.448846   \n",
       "1155468   0.254001      0.243356           0.290020          0.234187   \n",
       "15868129 -0.211707     -0.152905          -0.230486         -0.185077   \n",
       "3019239   0.410066      0.421252           0.363763          0.406276   \n",
       "3073616  -0.205507     -0.207154          -0.250811         -0.255881   \n",
       "...            ...           ...                ...               ...   \n",
       "3743583   0.322778      0.307786           0.314589          0.303186   \n",
       "12716752  0.007400     -0.013815           0.020399         -0.005707   \n",
       "7373832   0.031423      0.012354           0.005661          0.017594   \n",
       "9799516   0.107481      0.092703           0.148317          0.092146   \n",
       "2246794   0.488671      0.489795           0.457115          0.495034   \n",
       "\n",
       "          WT(ho)_YPDRapa  gat1_YPD  ...  dal80_YPEtOH  rtg1_CStarve  \\\n",
       "3959733         0.423015  0.436674  ...      0.462554      0.422464   \n",
       "1155468         0.246233  0.244152  ...      0.252488      0.252090   \n",
       "15868129       -0.181239 -0.203021  ...     -0.224674     -0.145569   \n",
       "3019239         0.405590  0.405143  ...      0.387864      0.411548   \n",
       "3073616        -0.201851 -0.210255  ...     -0.245164     -0.165162   \n",
       "...                  ...       ...  ...           ...           ...   \n",
       "3743583         0.300816  0.321936  ...      0.296849      0.326275   \n",
       "12716752       -0.009489  0.001280  ...      0.105331      0.009857   \n",
       "7373832         0.009611  0.026277  ...     -0.015209      0.028969   \n",
       "9799516         0.076100  0.121516  ...      0.104341      0.135002   \n",
       "2246794         0.490528  0.485176  ...      0.495131      0.494034   \n",
       "\n",
       "          rtg3_YPDRapa  gln3_YPDRapa  rtg3_Urea  gcn4_YPDDiauxic  dal81_Urea  \\\n",
       "3959733       0.435829      0.442340   0.420541         0.455527    0.440694   \n",
       "1155468       0.244590      0.231848   0.238815         0.259005    0.223404   \n",
       "15868129     -0.173586     -0.186482  -0.178214        -0.188925   -0.185918   \n",
       "3019239       0.409003      0.406112   0.414925         0.347930    0.425920   \n",
       "3073616      -0.200771     -0.208196  -0.238111        -0.226597   -0.180216   \n",
       "...                ...           ...        ...              ...         ...   \n",
       "3743583       0.308896      0.304540   0.241789         0.304318    0.310999   \n",
       "12716752     -0.011334     -0.002719   0.020440        -0.057969    0.020371   \n",
       "7373832       0.015254      0.014853   0.030025         0.073373    0.029154   \n",
       "9799516       0.065076      0.059805   0.143311         0.111416    0.154097   \n",
       "2246794       0.494767      0.487180   0.495261         0.467383    0.494825   \n",
       "\n",
       "          rtg1_Glutamine  rtg1_MinimalGlucose  dal82_YPD  \n",
       "3959733         0.457051             0.453254   0.419872  \n",
       "1155468         0.237021             0.200676   0.245670  \n",
       "15868129       -0.123766            -0.177847  -0.202909  \n",
       "3019239         0.389254             0.442493   0.410184  \n",
       "3073616        -0.188619            -0.210292  -0.211100  \n",
       "...                  ...                  ...        ...  \n",
       "3743583         0.294238             0.308701   0.322012  \n",
       "12716752       -0.001444             0.007230  -0.003173  \n",
       "7373832         0.011944             0.023508   0.028704  \n",
       "9799516         0.089413             0.105142   0.116481  \n",
       "2246794         0.487545             0.470948   0.478588  \n",
       "\n",
       "[1000 rows x 134 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_random_1k"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Get all perturbed edges for GCN4\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene1</th>\n",
       "      <th>gene2</th>\n",
       "      <th>dal82_MinimalGlucose</th>\n",
       "      <th>dal81_YPDDiauxic</th>\n",
       "      <th>gln3_YPD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>YDL248W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.126697</td>\n",
       "      <td>0.147686</td>\n",
       "      <td>0.155723</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>YDL247W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.039374</td>\n",
       "      <td>0.040146</td>\n",
       "      <td>0.044629</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>YDL246C</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.029832</td>\n",
       "      <td>0.030519</td>\n",
       "      <td>0.034649</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>YDL245C</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.058362</td>\n",
       "      <td>0.059531</td>\n",
       "      <td>0.066353</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>YDL244W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.200949</td>\n",
       "      <td>0.221537</td>\n",
       "      <td>0.241537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58639</th>\n",
       "      <td>Q0255</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>-0.012250</td>\n",
       "      <td>-0.010516</td>\n",
       "      <td>0.002222</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58648</th>\n",
       "      <td>Q0275</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.212287</td>\n",
       "      <td>0.188369</td>\n",
       "      <td>0.202799</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58657</th>\n",
       "      <td>RPM1</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.002418</td>\n",
       "      <td>0.003416</td>\n",
       "      <td>0.010498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58666</th>\n",
       "      <td>KANMX</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.758731</td>\n",
       "      <td>0.721745</td>\n",
       "      <td>0.758743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58675</th>\n",
       "      <td>NATMX</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.545534</td>\n",
       "      <td>0.519890</td>\n",
       "      <td>0.495521</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>6520 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         gene1    gene2  dal82_MinimalGlucose  dal81_YPDDiauxic  gln3_YPD\n",
       "4      YDL248W  YEL009C              0.126697          0.147686  0.155723\n",
       "13     YDL247W  YEL009C              0.039374          0.040146  0.044629\n",
       "22     YDL246C  YEL009C              0.029832          0.030519  0.034649\n",
       "31     YDL245C  YEL009C              0.058362          0.059531  0.066353\n",
       "40     YDL244W  YEL009C              0.200949          0.221537  0.241537\n",
       "...        ...      ...                   ...               ...       ...\n",
       "58639    Q0255  YEL009C             -0.012250         -0.010516  0.002222\n",
       "58648    Q0275  YEL009C              0.212287          0.188369  0.202799\n",
       "58657     RPM1  YEL009C              0.002418          0.003416  0.010498\n",
       "58666    KANMX  YEL009C              0.758731          0.721745  0.758743\n",
       "58675    NATMX  YEL009C              0.545534          0.519890  0.495521\n",
       "\n",
       "[6520 rows x 5 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_bonobos = pd.read_csv('../../bonobo_paper_yeast//results/bonobo_20230908/bonobo_inferelator_sparse_20230908_deletedgenes.csv')\n",
    "df_bonobos[df_bonobos['gene2']=='YEL009C'].loc[:,['gene1','gene2','dal82_MinimalGlucose','dal81_YPDDiauxic','gln3_YPD']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#gene_maps = {'dal81':'YIR023W', 'dal82':'YNL314W','dal80':'YKR034W','gat1':'YFL021W', 'gln3':'YER040W', 'gzf3':'YJL110C', 'gcn4':'YEL009C', 'stp1':'YDR463W', 'stp2':'YHR006W', 'rtg1':'YOL067C', 'rtg3':'YBL103C' }\n",
    "\n",
    "df_gcn4 = get_gene_bonobo_dataframe(nets_fn[:3], gene = 'YEL009C')\n",
    "df_gcn4.to_csv(output_folder+'bonobo_gcn4.csv', index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>gene1</th>\n",
       "      <th>gene2</th>\n",
       "      <th>dal82_MinimalGlucose</th>\n",
       "      <th>dal81_YPDDiauxic</th>\n",
       "      <th>gln3_YPD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>YDL248W</th>\n",
       "      <td>YDL248W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.126809</td>\n",
       "      <td>0.147620</td>\n",
       "      <td>0.155591</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL244W</th>\n",
       "      <td>YDL244W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.201121</td>\n",
       "      <td>0.221536</td>\n",
       "      <td>0.241369</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL243C</th>\n",
       "      <td>YDL243C</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.209790</td>\n",
       "      <td>0.234494</td>\n",
       "      <td>0.244827</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL241W</th>\n",
       "      <td>YDL241W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>-0.096724</td>\n",
       "      <td>-0.047144</td>\n",
       "      <td>-0.111439</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YDL240W</th>\n",
       "      <td>YDL240W</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.483571</td>\n",
       "      <td>0.454745</td>\n",
       "      <td>0.494752</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>X21S_rRNA</th>\n",
       "      <td>X21S_rRNA</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.338247</td>\n",
       "      <td>0.340260</td>\n",
       "      <td>0.358300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q0160</th>\n",
       "      <td>Q0160</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.023395</td>\n",
       "      <td>0.042311</td>\n",
       "      <td>0.043935</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Q0275</th>\n",
       "      <td>Q0275</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.212138</td>\n",
       "      <td>0.188420</td>\n",
       "      <td>0.202727</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>KANMX</th>\n",
       "      <td>KANMX</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.758720</td>\n",
       "      <td>0.722044</td>\n",
       "      <td>0.758733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NATMX</th>\n",
       "      <td>NATMX</td>\n",
       "      <td>YEL009C</td>\n",
       "      <td>0.545490</td>\n",
       "      <td>0.520064</td>\n",
       "      <td>0.495894</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5804 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               gene1    gene2  dal82_MinimalGlucose  dal81_YPDDiauxic  \\\n",
       "YDL248W      YDL248W  YEL009C              0.126809          0.147620   \n",
       "YDL244W      YDL244W  YEL009C              0.201121          0.221536   \n",
       "YDL243C      YDL243C  YEL009C              0.209790          0.234494   \n",
       "YDL241W      YDL241W  YEL009C             -0.096724         -0.047144   \n",
       "YDL240W      YDL240W  YEL009C              0.483571          0.454745   \n",
       "...              ...      ...                   ...               ...   \n",
       "X21S_rRNA  X21S_rRNA  YEL009C              0.338247          0.340260   \n",
       "Q0160          Q0160  YEL009C              0.023395          0.042311   \n",
       "Q0275          Q0275  YEL009C              0.212138          0.188420   \n",
       "KANMX          KANMX  YEL009C              0.758720          0.722044   \n",
       "NATMX          NATMX  YEL009C              0.545490          0.520064   \n",
       "\n",
       "           gln3_YPD  \n",
       "YDL248W    0.155591  \n",
       "YDL244W    0.241369  \n",
       "YDL243C    0.244827  \n",
       "YDL241W   -0.111439  \n",
       "YDL240W    0.494752  \n",
       "...             ...  \n",
       "X21S_rRNA  0.358300  \n",
       "Q0160      0.043935  \n",
       "Q0275      0.202727  \n",
       "KANMX      0.758733  \n",
       "NATMX      0.495894  \n",
       "\n",
       "[5804 rows x 5 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_gcn4"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "nb",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
